﻿using Messhall.Framework.Domain.DomainObject;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Messhall.Framework.Domain.DomainObject
{
    public class DomainObjectsBase
    {
        protected EntityBoBase Entity;

        [NotMapped] public List<string> DomainEvens { get; set; }


        public void SetCreateTime(DateTime? dateTime = null)
        {
            this.Entity.CreateTime = dateTime.HasValue ? dateTime.Value : DateTime.Now;
        }

        public void SetUpdateTime(DateTime? dateTime = null)
        {
            this.Entity.UpdateTime = dateTime.HasValue ? dateTime.Value : DateTime.Now;
        }

        public void SetIsDelete(bool isDelete)
        {
            this.Entity.IsDelete = isDelete;
        }

        public Guid GetKeyId()
        {
            return this.Entity.KeyId;
        }

        public void SetKeyId(Guid keyId)
        {
            this.Entity.SetKeyId(keyId);
        }

        public DateTime GetCreateTime()
        {
            return this.Entity.CreateTime;
        }
        
        public void SetCreateTime(DateTime createTime)
        {
            this.Entity.CreateTime = createTime;
        }

        public DateTime GetUpdateTime()
        {
            return this.Entity.UpdateTime;
        }

        public void SetUpdateTime(DateTime updateTime)
        {
            this.Entity.UpdateTime = updateTime;
        }
        
        public byte[] GetRowVersion()
        {
            return this.Entity.RowVersion;
        }
    }
}